/*
 * Gerente
 * 
 * Versao 1.0
 * 
 * 25/05/2013
 * 
 * Autor: Bhetynna Catalunha
 * 
 */
package edu.Ufes.exeSwing.Model;

import static edu.Ufes.exeSwing.Model.Funcionario.SALARIOBASE;
import edu.Ufes.exeSwing.Interface.Autenticavel;

/**
 *
 * @author bhetynnacatalunha
 */
public class Gerente extends Funcionario implements Autenticavel {

    private Agencia ag1, ag2;

    /**
     * @return the ag1
     */
    public Gerente(String pNome, Agencia pAgencia1, Agencia pAgencia2, String pCPF, String pEndereco, String pDataNascimento, String pNomeUsuario) {
        super(pNome, pCPF, pEndereco, pDataNascimento, pNomeUsuario);
        this.ag1 = pAgencia1;
        this.ag2 = pAgencia2;
        //this.calculaSalario();
    }

    public Agencia getAg1() {
        return ag1;
    }

    /**
     * @param ag1 the ag1 to set
     */
    public void setAg1(Agencia ag1) {
        this.ag1 = ag1;
    }

    /**
     * @return the ag2
     */
    public Agencia getAg2() {
        return ag2;
    }

    /**
     * @param ag2 the ag2 to set
     */
    public void setAg2(Agencia ag2) {
        this.ag2 = ag2;
    }

    @Override
    public boolean autentica(int psenha) {
        boolean retorno = false;

        return retorno;

    }

    @Override
    protected void calculaSalario() {
        double adicional = 0;
        int numClientes1 = 0;
        int numClientes2 = 0;
        if (getAg1() != null) {
            if (this.getAg1().getUf().equals("ES")) {
                adicional += SALARIOBASE * 0.25;
            } else if (this.getAg1().getUf().equals("MG")) {
                adicional += SALARIOBASE * 0.30;
            } else if (this.getAg1().getUf().equals("SP")) {
                adicional += SALARIOBASE * 0.05;
            }
            numClientes1 = this.ag1.getClientes().size();
        }
        if (getAg2() != null) {
            if (this.getAg2().getUf().equals("ES")) {
                adicional += SALARIOBASE * 0.25;
            } else if (this.getAg2().getUf().equals("MG")) {
                adicional += SALARIOBASE * 0.30;
            } else if (this.getAg2().getUf().equals("SP")) {
                adicional += SALARIOBASE * 0.05;
            }
            numClientes2 = this.ag2.getClientes().size();
        }

        this.setSalarioTotal(SALARIOBASE + adicional + numClientes1 + numClientes2);
    }

    @Override
    public String toString() {
        if ((ag1 != null) && (ag2 !=null)) {
            return super.toString() + "#" + ag1.getCodigo().toString() + "#" + ag2.getCodigo().toString(); //To change body of generated methods, choose Tools | Templates.
        }
        if (ag1 != null) {
            return super.toString() + "#" + ag1.getCodigo().toString(); //To change body of generated methods, choose Tools | Templates.
        }
        if (ag2 != null) {
            return super.toString() + "#" + ag2.getCodigo().toString(); //To change body of generated methods, choose Tools | Templates.
        }
        return super.toString();
    }
}
